/**
 * Project Name:swt-hello <br/>
 * File Name:App.java <br/>
 * Package Name:com.ftu.z <br/>
 */
package com.ftu.swt.basic4;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;


/**
 * <p>  </p>
 * @version 1.0 2018年11月22日 mq 修改内容:初版
 */
public class UsingCoolBar {
    public static void main(String[] args) {
        final Display display = Display.getDefault();
        Shell shell1 = new Shell(display);
        shell1.setText("shell1");
        shell1.setSize(400, 400);
        
        CoolBar coolBar = new CoolBar(shell1, SWT.NONE);
        coolBar.setBounds(0, 0, 300, 30);
        
        CoolItem coolItem_1 = new CoolItem(coolBar, SWT.NONE);
        coolItem_1.setText("coolItem_1");
        
        Button btnHello = new Button(coolBar, SWT.NONE);
        coolItem_1.setControl(btnHello);
        coolItem_1.setSize(coolItem_1.computeSize(100, 25));
        btnHello.setImage(display.getSystemImage(SWT.ICON_ERROR));
        btnHello.setText("hello");
        btnHello.setSize(25, 25);
        
        CoolItem coolItem_2 = new CoolItem(coolBar, SWT.NONE);
        
        Combo combo = new Combo(coolBar, SWT.NONE);
        coolItem_2.setControl(combo);
        coolItem_2.setSize(coolItem_2.computeSize(50, 25));
        combo.setItems(new String[]{"1","2"});
        combo.setSize(50, 25);
//        coolItem_2.setImage(display.getSystemImage(SWT.ICON_ERROR));
        
        
        CoolBar coolBar_1 = new CoolBar(shell1, SWT.FLAT);
        coolBar_1.setBounds(10, 48, 150, 30);
        ToolBar toolBar = new ToolBar(coolBar_1, SWT.FLAT | SWT.RIGHT);
        toolBar.setBounds(0, 48, 374, 35);
        toolBar.setSize(200, 20);
        CoolItem coolItem = new CoolItem(coolBar_1, SWT.NONE);
        coolItem.setControl(toolBar);
        coolItem.setSize(100, 20);
        
        ToolItem tltmHello = new ToolItem(toolBar, SWT.NONE);
        tltmHello.setText("hello");
        
        ToolItem tltmWorld = new ToolItem(toolBar, SWT.NONE);
        tltmWorld.setText("world");
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        shell1.open();
        while(!shell1.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
        
    }
}
